package com.hqu.ms;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.googlecode.androidannotations.annotations.AfterViews;
import com.googlecode.androidannotations.annotations.EActivity;

@EActivity(R.layout.ms_multiloc_main)
public class MultiLocationActivity extends SherlockFragmentActivity {
	
	private static final String CONTENT = "CONTENT";
	MultiLocFragment fragment;
	
	@AfterViews
	void afterViews(){
		FragmentManager fm = getSupportFragmentManager();
		fragment = (MultiLocFragment) fm.findFragmentByTag(CONTENT);
		if(fragment == null){
			fragment = MultiLocFragment_.builder().build();
		}
		
		fm.beginTransaction().add(R.id.llmain, fragment, CONTENT).commit();
		
	}
	
	@Override
	public void onBackPressed() {
		finishThis();
	}
	
	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		fragment.mMapView.onSaveInstanceState(outState);
	}
	
	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		super.onRestoreInstanceState(savedInstanceState);
		fragment.mMapView.onRestoreInstanceState(savedInstanceState);
	}
	
	public void finishThis(){
		finish();
		overridePendingTransition(R.anim.base_stay_orig, R.anim.base_slide_right_out);
	}
}
